<?php

namespace app\admin\model;

use think\Model;
use think\Session;

class Supply extends Model
{
    // 表名
    protected $name = 'supply';
    protected $insert = ['userid'];

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';


    protected function setUseridAttr()
    {
        $a = Session::get('admin');
        return $a['userid'];

    }
    public function getCreatetimeAttr($value, $data)
    {
       return date("Y-m-d H:i:s",$value);
    }

    public function getUseridAttr($value, $data)
    {
        $model = model("admin");
        $info = $model->where(array('userid'=>$value))->find();
        return $info['username'];
    }







}
